export enum OrderState {
  WAITING_FOR_PAYMENT = 1, // 待支付
  WAITING_FOR_ACCEPTANCE = 2, // 待接单
  ORDER_ACCEPTED = 3, // 已接单
  PRODUCTION_COMPLETED = 4, // 制作完成（待取餐）
  IN_DELIVERY = 5, // 配送中
  ORDER_COMPLETED = 6, // 已完成
  ORDER_EVALUATED = 7, // 已评价
  ORDER_CANCELED = -1, // 超时未支付（已取消）
  APPLY_FOR_AFTER_SALE = -31, // 申请售后
  REFUNDING = -32, // 退款中
  REFUND_COMPLETED = -33 // 退款完成（已取消）
}
export class OrderStateGroups {
  public static readonly cancellableStates: OrderState[] = [
    OrderState.WAITING_FOR_PAYMENT,
    OrderState.WAITING_FOR_ACCEPTANCE
  ]
  public static readonly finalStates: OrderState[] = [
    OrderState.ORDER_COMPLETED,
    OrderState.ORDER_EVALUATED,
    OrderState.ORDER_CANCELED,
    OrderState.REFUND_COMPLETED
  ]
  public static readonly canAfterSalesStates: OrderState[] = [
    OrderState.ORDER_ACCEPTED,
    OrderState.PRODUCTION_COMPLETED,
    OrderState.IN_DELIVERY,
    OrderState.ORDER_COMPLETED,
    OrderState.ORDER_EVALUATED
  ]
}
export function orderStateLabelOf(value?: number): string {
  if (value === OrderState.WAITING_FOR_PAYMENT) return '待支付'
  if (value === OrderState.WAITING_FOR_ACCEPTANCE) return '待接单'
  if (value === OrderState.ORDER_ACCEPTED) return '已接单'
  if (value === OrderState.PRODUCTION_COMPLETED) return '待取餐'
  if (value === OrderState.IN_DELIVERY) return '配送中'
  if (value === OrderState.ORDER_COMPLETED) return '已完成'
  if (value === OrderState.ORDER_EVALUATED) return '已评价'
  if (value === OrderState.ORDER_CANCELED) return '已取消'
  if (value === OrderState.APPLY_FOR_AFTER_SALE) return '申请售后'
  if (value === OrderState.REFUNDING) return '退款中'
  if (value === OrderState.REFUND_COMPLETED) return '退款完成'
  return ''
}

export function orderStateTipsOf(value?: number): string {
  if (value === OrderState.WAITING_FOR_PAYMENT) return '如需下单，请尽快支付'
  if (value === OrderState.WAITING_FOR_ACCEPTANCE) return '如长时间不接单可申请退单'
  if (value === OrderState.ORDER_ACCEPTED) return '商家已接单，请耐心等待'
  if (value === OrderState.PRODUCTION_COMPLETED) return '餐食已制作完成，请尽快取餐'
  if (value === OrderState.IN_DELIVERY) return '您的外卖正在配送中'
  if (value === OrderState.ORDER_COMPLETED) return '订单已完成'
  if (value === OrderState.ORDER_EVALUATED) return '订单已评价'
  if (value === OrderState.ORDER_CANCELED) return '订单已取消'
  if (value === OrderState.APPLY_FOR_AFTER_SALE) return '正在申请售后，待商家审核'
  if (value === OrderState.REFUNDING) return '退款处理中，请耐心等待'
  if (value === OrderState.REFUND_COMPLETED) return '退款完成，订单已取消'
  return ''
}
